package com.ranlen.ems_vue.config;

import com.ranlen.ems_vue.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Autowired
    RedisTemplate redisTemplate;
    @Autowired
    StringRedisTemplate stringRedisTemplate;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor(stringRedisTemplate,redisTemplate))
                .addPathPatterns("/**")
                .excludePathPatterns("/user/login",
                        "/css/**",
                        "/img/**",
                        "/js/**",
                        "/photos/**",
                        "/user/getImage",
                        "/user/register",
                        "/404.html",
                        "/login.html",
                        "/regist.html");
    }
}
